package SI::Insurance::AverageSalary;

use base qw/MyDB::Object/;


__PACKAGE__->meta->setup(
    table => 'AverageSalary',
    columns =>
    [
        year => { type => 'int', not_null => 1 },
        begin_time => { type => 'datetime',  not_null => 1 },
        end_time => { type => 'datetime', not_null => 1},
        months => { type => 'int', not_null => 1},
        avg_salary => { type => 'decimal' },
        all_avg_salary => { type => 'decimal' },
        bottom_line => { type => 'decimal'},
        ceil_line => { type => 'decimal'},

    ],
    allow_inline_column_values => 1,
    primary_key_columns => [ 'year' ],
);

sub init_tab {
	my $self = shift;
	my $stmt = 'CREATE TABLE IF NOT EXISTS AvgSalary (
                year INT NOT NULL ,                  /* 年度 */
                begin_time DATE NOT NULL,            /* 起始时间 */
                end_time DATE NOT NULL,              /* 终止时间 */
                months INT NOT NULL,                 /* 月数     */
                avg_salary DECIMAL(10,0) NOT NULL,   /* 非私营社平工资 */
                all_avg_salary DECIMAL(10,0) NOT NULL, /* 全口径社平工资 */
                bottom_line DECIMAL(10,0) NOT NULL,  /* 保底工资 */
                cell_line DECIMAL(10,0) NOT NULL     /* 封顶工资 */
                );';
    my $db = $self->init_db;
    my $dbh = $db->dbh or die $db->error;
    $db->do_transaction(sub {$dbh->do($stmt)})
        or die $db->error;
    return 1;
}


1;
